Function.RegisterNamespace("System.IO.FileStrategy");

System.IO.FileStrategy.Phantom=function(){
    var fs=null;

    // IFileStrategy Members
    this.DeleteFile=function(path){
        if(this.Exists(path)){
           fs.remove(path);        
        }
        return false;
    };
    
    this.Exists=function(path){
        if(!!path){
            return fs.exists(path)&&fs.isFile(path);
        }
        return false;
    };

    this.GetFile=function(path){
        if(this.Exists(path)){
            return fs.read(path);
        }
        return null;
    };
        
    this.SaveFile=function(path,text){
        fs.write(path,text,"w");
    };

    // IStrategySpecification Members
    this.IsSatisfiedBy=function(candidate){
        if(typeof(phantom)!="undefined"&&typeof(require)=="function"){
            fs=require("fs");
            return true;
        }
        return false;
    };

};

System.IO.FileStrategy.Phantom.Implement(System.IO.FileStrategy.IFileStrategy,'System.IO.FileStrategy.Phantom');
System.IO.FileStrategy.Phantom.Implement(System.Script.Strategy.IStrategySpecification,'System.IO.FileStrategy.Phantom');

System.IO.File.Strategies.Add(System.IO.FileStrategy.Phantom,0);